﻿#ifndef LOGWIDGET_H
#define LOGWIDGET_H

#include <Windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <ShlObj.h>
#pragma comment(lib, "Shell32.lib")

#define LOG_LEVEL_INFO		"INFO"
#define LOG_LEVEL_WARN		"WARN"
#define LOG_LEVEL_ERROR		"ERROR"

typedef struct tagLOG_SERVICE_CONTEXT_ {
    FILE *	pFile;	//暂未使用
    char	chFileName[MAX_PATH];
    HANDLE	logMutex;
}LOG_SERVICE_CONTEXT, *PLOG_SERVICE_CONTEXT;


BOOL InitLogService(char *pFileName, int csidl, PLOG_SERVICE_CONTEXT *ppLogContext);
void CloseLogService();
/*
写入日志 最大长度1024
@pSourceName, 源文件名
@iLineNum， 源文件所在行
@iLevel,	等级
@fmt,...	内容
*/
int WriteToLog(PLOG_SERVICE_CONTEXT pLogContext, const char *pSourceName, int iLineNum, const char *pLevel, const char *fmt, ...);

#endif // LOGWIDGET_H
